﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 工艺流程步骤
    /// </summary>
    public partial class CraftStep : BusEntity
    {        
        /// <summary>
        /// 步骤编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 步骤名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 步骤图标
        /// </summary>
        public string Icon { set; get; }

        /// <summary>
        /// 排序号
        /// </summary>
        public int Sort { set; get; }
    }

    public partial class CraftStep : BusEntity
    {
        public List<CraftStepProcess> Process { set; get; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class CraftStepTypeConfig : BusEntityTypeConfig<CraftStep>, IEntityTypeConfiguration<CraftStep>
    {
        public override void Configure(EntityTypeBuilder<CraftStep> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Icon).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.Sort);
            #endregion

            #region 备注
            builder.HasComment("工艺流程步骤");
            builder.Property(p => p.Code).HasComment("步骤编码");
            builder.Property(p => p.Name).HasComment("步骤名称");
            builder.Property(p => p.Icon).HasComment("步骤图标");
            builder.Property(p => p.Sort).HasComment("排序号");
            #endregion

            #region 种子数据
            builder.HasData(new CraftStep() { Id = "1001", Name = "来料缓存", Code = "1001", Icon = "dropbox", Sort = 1, CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CraftStep() { Id = "1002", Name = "拼板卷圆", Code = "1002", Icon = "dropbox", Sort = 2, CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CraftStep() { Id = "1003", Name = "成型件预装", Code = "1003", Icon = "dropbox", Sort = 3, CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CraftStep() { Id = "1004", Name = "筒体加工", Code = "1004", Icon = "dropbox", Sort = 4, CreateUserId = "1", ModifyUserId = "1" });
            builder.HasData(new CraftStep() { Id = "1005", Name = "筒体检测", Code = "1005", Icon = "dropbox", Sort = 5, CreateUserId = "1", ModifyUserId = "1" });
            #endregion
        }
    }
}
